package com.ysqcould.web.controller.message;


import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import com.ysqcould.message.domain.DatumChange;
import com.ysqcould.message.service.IDatumChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 协会意见反馈和资料变更Controller
 * 
 * @author ruoyi
 * @date 2022-06-30
 */
@RestController
@RequestMapping("/message/change")
public class DatumChangeController extends BaseController
{
    @Autowired
    private IDatumChangeService datumChangeService;

    /**
     * 查询协会意见反馈和资料变更列表
     */
    @PreAuthorize("@ss.hasPermi('message:change:list')")
    @GetMapping("/list")
    public TableDataInfo list(DatumChange datumChange)
    {
        startPage();
        List<DatumChange> list = datumChangeService.selectDatumChangeList(datumChange);
        return getDataTable(list);
    }

    /**
     * 导出协会意见反馈和资料变更列表
     */
    @PreAuthorize("@ss.hasPermi('message:change:export')")
    @Log(title = "协会意见反馈和资料变更", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DatumChange datumChange)
    {
        List<DatumChange> list = datumChangeService.selectDatumChangeList(datumChange);
        ExcelUtil<DatumChange> util = new ExcelUtil<DatumChange>(DatumChange.class);
        util.exportExcel(response, list, "协会意见反馈和资料变更数据");
    }

    /**
     * 获取协会意见反馈和资料变更详细信息
     */
    @PreAuthorize("@ss.hasPermi('message:change:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(datumChangeService.selectDatumChangeById(id));
    }

    /**
     * 新增协会意见反馈和资料变更
     */
    @PreAuthorize("@ss.hasPermi('message:change:add')")
    @Log(title = "协会意见反馈和资料变更", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DatumChange datumChange)
    {
        return toAjax(datumChangeService.insertDatumChange(datumChange));
    }

    /**
     * 修改协会意见反馈和资料变更
     */
    @PreAuthorize("@ss.hasPermi('message:change:edit')")
    @Log(title = "协会意见反馈和资料变更", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DatumChange datumChange)
    {
        return toAjax(datumChangeService.updateDatumChange(datumChange));
    }

    /**
     * 删除协会意见反馈和资料变更
     */
    @PreAuthorize("@ss.hasPermi('message:change:remove')")
    @Log(title = "协会意见反馈和资料变更", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(datumChangeService.deleteDatumChangeByIds(ids));
    }
}
